//
//  UIBarButtonItem+YY.swift
//  SinaWeibo
//
//  Created by 胡阳 on 16/5/20.
//  Copyright © 2016年 young4ever. All rights reserved.
//

import UIKit

extension UIBarButtonItem {


    /**
     把UIButton包装成UIBarButtonItem
     
     - parameter normalImage: 普通状态图片
     - parameter target:      事件的监听对象
     - parameter action:      时间的方法
     
     - returns: 包装好的item
     */
    class func packageButtonToItem(normalImage: String, target: AnyObject?, action: Selector) -> UIBarButtonItem {
    
        let btn = UIButton()
        btn.setImage(UIImage(named: normalImage + "_highlighted"), forState: UIControlState.Highlighted)
        btn.setImage(UIImage(named: normalImage), forState: UIControlState.Normal)
        btn.sizeToFit()
        btn.addTarget(target, action: action, forControlEvents: UIControlEvents.TouchUpInside)
        let item = UIBarButtonItem(customView: btn)
        return item
    }



}
